using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using System.Net.Mail;
using System.Net;

public partial class UserControls_ContactForm : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void sendButton_Click(object sender, EventArgs e)
    {
        //create e-mail message for Admin

        string message = string.Empty;
        FileInfo file1 = new FileInfo(Server.MapPath("ConfirmationEmails\\CustomerQuestion.htm"));
        message = file1.OpenText().ReadToEnd();
        message = message.Replace("$Name", nameTextBox.Text);
        message = message.Replace("$Phone", phoneTextBox.Text);
        message = message.Replace("$Message", messageTextBox.Text);
        
        string subject = "Zapytanie od - " + nameTextBox.Text;
        
        MailMessage mail = new MailMessage();
        NetworkCredential cred = new NetworkCredential(HunterShopConfiguration.HunterShopEmailAddress,
        HunterShopConfiguration.HunterShopEmailPassword);

        //send e-mail to Admin
        mail.To.Add(HunterShopConfiguration.HunterShopEmailAddress);
        mail.Subject = subject;
        mail.From = new MailAddress(emailTextBox.Text);
        mail.IsBodyHtml = true;
        mail.Body = message.ToString();
        SmtpClient smtp = new SmtpClient("mail.hostedwindows.pl");
        //smtp.UseDefaultCredentials = false;
        //smtp.EnableSsl = true;
        smtp.Credentials = cred;
        //smtp.Port = 587;
        smtp.Send(mail);
       
    }
}
